import React, { Component ,PureComponent} from 'react'

export default class ClassComponent extends PureComponent {
    constructor(props){
      super()
      this.state={
        name:'张三',
        counts:0,
        NUM:{
          a:0
        }
      }
    }
      //  shouldComponentUpdate(pro,state){
      //      console.log(pro,state,'should');
      //      if (state.name===this.state.name) {
      //       return false
      //      }else{
      //       return true
      //      }
      //  }
     componentDidMount(props){
        console.log(props,'componentDidMount');
      // this.timer= setInterval(()=>{
      //       this.setState({
      //           counts:this.state.counts+1
      //       })
      //   },1000)
    }
     componentDidUpdate(props){
        console.log(props,'componentDidUpdate');
   }
     changeName=()=>{
      this.state.NUM.a=100000
     this.setState({
        name:'王五',
        NUM: this.state.NUM
     })
  }
  render() {
    console.log('this.render');
    return (
      <div>
        ClassComponent   name:{this.state.name} ppp:{this.state.counts}
        NUM:{this.state.NUM.a}
        <button onClick={()=>this.changeName()}>changeName</button>
      </div>
    )
  }
  componentWillUnmount(){
  clearInterval(this.timer)
console.log(1);
  }
}
